<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>DOM</title>
</head>

<body>

    <img id="light" src="img/off.gif"> <br>

    <div class="cls">传智教育</div> <br>
    <div class="cls">黑马程序员</div> <br>

    <input type="checkbox" name="hobby"> 电影
    <input type="checkbox" name="hobby"> 旅游
    <input type="checkbox" name="hobby"> 游戏
    <br>

</body>
<script>
    //1. 点亮灯泡
    // var img = document.getElementById("light");
    // img.src = "img/on.gif"


    //2. 添加数据 "very good"   
    // 获取元素内容： innerHTML
    // var divs = document.getElementsByTagName("div");
    // for (let i = 0; i < divs.length; i++) {
    //     const div = divs[i];
    //     div.innerHTML =  div.innerHTML + "<font color='red'> very good </font>"
    // }


    //3. 复选框选中
    var ins = document.getElementsByName("hobby");
    for (let i = 0; i < ins.length; i++) {
        const checkbox = ins[i];
        checkbox.checked = true;
    }
</script>

</html>